home *** CD-ROM | disk | FTP | other *** search
Wrap
#========================================== # COMPRESSION SETTINGS #========================================== CRCCheck force SetCompressor /SOLID /FINAL lzma #========================================== # DEFINES #========================================== !include "Defines.nsi" !define NAME "System Files Updater" !define MUI_ICON "Assets\Images\Icons\System Files Updater.ico" !define MUI_WELCOMEFINISHPAGE_BITMAP "Assets\Images\Wizards\Update.bmp" #========================================== # INCLUDES #========================================== !include "MUI.nsh" !include "Sections.nsh" !include "Get Parameters.nsi" !addplugindir "Assets\Plugins" #========================================== # INSTALLER INFORMATION #========================================== Name "${NAME}" OutFile "Assets\Tools\${NAME}.exe" #========================================== # INTERFACE SETTINGS #========================================== Caption "${NAME}" BrandingText "${COPYRIGHT} ${PRODUCT_PUBLISHER}" ShowInstDetails show InstallColors /windows InstallButtonText "Update" Var AppDir Var FileSize Var Office Var UpdatedFileCount #========================================== # PAGES #========================================== !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through updating the system files on your computer.\r\n\r\n\ This will only update files on your system that have reverted back to the default XP look. It will NOT reapply visual styles, cursors, sounds or anything else non-system file related.\r\n\r\n\ Click Update to start." !define MUI_WELCOMEPAGE_TITLE "Welcome to the ${NAME} Wizard" !insertmacro MUI_PAGE_WELCOME !define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Update Complete" !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "The update was completed successfully" !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE_NOAUTOCLOSE #========================================== # LANGUAGES #========================================== !insertmacro MUI_LANGUAGE "English" #========================================== # INSTALLER MACROS #========================================== !macro UpdateFile UNUSED FileName TargetFolder !define UNIQUE_LINE ${__LINE__} #CHECK IF FILE EXISTS IfFileExists "${TargetFolder}\${FileName}" 0 END_${UNIQUE_LINE} IfFileExists "${INST_RESOURCES}\${FileName}" 0 END_${UNIQUE_LINE} #READ REGISTRY FILE SIZE ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}" StrCmp $0 "" END_${UNIQUE_LINE} #READ ACTUAL FILE SIZE Push "${TargetFolder}\${FileName}" Call GetFileSize Pop $FileSize #CHECK IF FILE SIZES DIFFER StrCmp "$0" "$FileSize" END_${UNIQUE_LINE} #DISPLAY CURRENTLY UPDATING FILE !insertmacro SetDetailsPrint "Updating File: ${FileName}" #BACKUP FILE ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}" Delete "${INST_BACKUP}\${FileName}" CopyFiles /SILENT "${TargetFolder}\${FileName}" "${INST_BACKUP}" #MODIFY FILE CopyFiles /SILENT "${TargetFolder}\${FileName}" "${INST_TEMPFILES}" StrCpy "$OUTDIR" "${INST}" ExecWait '"${INST_TOOLS}\ResHacker.exe" -script "${INST_RESOURCES}\${FileName}\${FileName}.txt"' IfFileExists "${INST_NEWFILES}\${FileName}" +3 DeleteRegValue HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}" Goto END_${UNIQUE_LINE} #WRITE NEW FILE SIZE TO REGISTRY Push "${INST_NEWFILES}\${FileName}" Call GetFileSize Pop $FileSize WriteRegStr HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}" "$FileSize" #REPLACE FILE IN CACHE IfFileExists "$SYSDIR\dllcache\${FileName}" 0 +2 CopyFiles /SILENT "${INST_NEWFILES}\${FileName}" "$SYSDIR\dllcache\${FileName}" IfFileExists "$WINDIR\ServicePackFiles\i386\${FileName}" 0 +2 CopyFiles /SILENT "${INST_NEWFILES}\${FileName}" "$WINDIR\ServicePackFiles\i386\${FileName}" #REPLACE FILE IN TARGET FOLDER Delete "${TargetFolder}\${FileName}.${PRODUCT_NAME}" Rename "${INST_NEWFILES}\${FileName}" "${TargetFolder}\${FileName}.${PRODUCT_NAME}" ExecCmd::exec '"${INST_TOOLS}\MoveEx.exe" "${TargetFolder}\${FileName}.${PRODUCT_NAME}" "${TargetFolder}\${FileName}"' #COUNT UPDATED FILES IntOp $UpdatedFileCount $UpdatedFileCount + 1 SetRebootFlag true END_${UNIQUE_LINE}: !undef UNIQUE_LINE !macroend !macro ComCtl32 UNUSED FileName TargetFolder Number !define UNIQUE_LINE ${__LINE__} #CHECK IF FILE EXISTS IfFileExists "${TargetFolder}\${FileName}" 0 END_${UNIQUE_LINE} IfFileExists "${INST_RESOURCES}\${FileName}" 0 END_${UNIQUE_LINE} #READ REGISTRY FILE SIZE ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}${Number}" StrCmp $0 "" END_${UNIQUE_LINE} #READ ACTUAL FILE SIZE Push "${TargetFolder}\${FileName}" Call GetFileSize Pop $FileSize #CHECK IF FILE SIZES DIFFER StrCmp "$0" "$FileSize" END_${UNIQUE_LINE} #DISPLAY CURRENTLY INSTALLING FILE !insertmacro SetDetailsPrint "Updating File: ${FileName}" #BACKUP FILE Delete "${INST_BACKUP}\${FileName}${Number}" CopyFiles /SILENT "${TargetFolder}\${FileName}" "${INST_BACKUP}" Rename "${INST_BACKUP}\${FileName}" "${INST_BACKUP}\${FileName}${Number}" #MODIFY FILE SetRebootFlag true CopyFiles /SILENT "${TargetFolder}\${FileName}" "${INST_TEMPFILES}" StrCpy "$OUTDIR" "${INST}" ExecWait '"${INST_TOOLS}\ResHacker.exe" -script "${INST_RESOURCES}\${FileName}\${FileName}.txt"' IfFileExists "${INST_NEWFILES}\${FileName}" +3 DeleteRegValue HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}${Number}" Goto END_${UNIQUE_LINE} Rename "${INST_NEWFILES}\${FileName}" "${INST_NEWFILES}\${FileName}${Number}" #WRITE FILE SIZE TO REGISTRY Push "${INST_NEWFILES}\${FileName}${Number}" Call GetFileSize Pop $FileSize WriteRegStr HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}${Number}" "$FileSize" #REPLACE FILE IN TARGET FOLDER Delete "${TargetFolder}\${FileName}.${PRODUCT_NAME}" Delete "${TargetFolder}\${FileName}.delete" Rename "${TargetFolder}\${FileName}" "${TargetFolder}\${FileName}.delete" Rename "${INST_NEWFILES}\${FileName}${Number}" "${TargetFolder}\${FileName}" #COUNT UPDATED FILES IntOp $UpdatedFileCount $UpdatedFileCount + 1 END_${UNIQUE_LINE}: !undef UNIQUE_LINE !macroend !macro OfficeFiles MacroName FileName SubKey Entry #GET FILE PATH ReadRegStr $Office HKLM "${SubKey}" "${Entry}" Push $Office Call GetParent Pop $Office !insertmacro ${MacroName} "System Files\Office" "${FileName}" "$Office" IfFileExists "$Office\${FileName}.${PRODUCT_NAME}" 0 +9 Delete "$Office\${FileName}.delete" Rename "$Office\${FileName}" "$Office\${FileName}.delete" Rename "$Office\${FileName}.${PRODUCT_NAME}" "$Office\${FileName}" Delete "$Office\${FileName}.delete" Push "$Office\${FileName}" Call GetFileSize Pop $FileSize WriteRegStr HKLM "Software\${PRODUCT_NAME}\FILES" "${FileName}" "$FileSize" !macroend !macro SetDetailsPrint TextToPrint SetDetailsPrint both DetailPrint "${TextToPrint}" SetDetailsPrint none !macroend #========================================== # SECTION - PRE UPDATE (HIDDEN) #========================================== Section "Pre Update" !insertmacro SetDetailsPrint "Checking System Files..." !insertmacro SetDetailsPrint "" #CREATE DIRECTORIES IfFileExists "${INST}" 0 +3 CreateDirectory "${INST_NEWFILES}" CreateDirectory "${INST_TEMPFILES}" ExecCmd::exec "${INST_TOOLS}\wfpdisable.exe" SectionEnd #========================================== # SECTION - SYSTEM FILES #========================================== !include "System Files.nsi" !insertmacro SystemFiles "" "" "UpdateFile" #========================================== # SECTION - MISC FILES #========================================== Section "Logon Screen" !insertmacro UpdateFile "Extras\Logon Screen" "logonui.exe" "$SYSDIR" SectionEnd Section "Boot Screen" !insertmacro UpdateFile "Extras\Boot Screen\Normal" "ntkrnlmp.exe" "$SYSDIR" !insertmacro UpdateFile "Extras\Boot Screen\Normal" "ntkrnlpa.exe" "$SYSDIR" !insertmacro UpdateFile "Extras\Boot Screen\Normal" "ntoskrnl.exe" "$SYSDIR" IfFileExists "$SYSDIR\ntkrnlpa.exe.${PRODUCT_NAME}" 0 +2 ExecCmd::exec "${INST_TOOLS}\XVI32.exe $SYSDIR\ntkrnlpa.exe.${PRODUCT_NAME} /S=${INST_TOOLS}\ReplacePalette.xsc" IfFileExists "$SYSDIR\ntoskrnl.exe.${PRODUCT_NAME}" 0 +2 ExecCmd::exec "${INST_TOOLS}\XVI32.exe $SYSDIR\ntoskrnl.exe.${PRODUCT_NAME} /S=${INST_TOOLS}\ReplacePalette.xsc" IfFileExists "$SYSDIR\ntkrnlmp.exe.${PRODUCT_NAME}" 0 +2 ExecCmd::exec "${INST_TOOLS}\XVI32.exe $SYSDIR\ntkrnlmp.exe.${PRODUCT_NAME} /S=${INST_TOOLS}\ReplacePalette.xsc" SectionEnd #========================================== # SECTION - POST UPDATE (HIDDEN) #========================================== Section "Post Update" StrCmp "$UpdatedFileCount" "0" 0 MORETHANZERO !insertmacro SetDetailsPrint "Your system is already up to date. No files need updating at this time." Goto CLEANUP MORETHANZERO: IfSilent 0 NOTSILENT ReadRegDWORD $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" "EnableBalloonTips" StrCmp $0 "0" 0 +3 MessageBox MB_OK "The FlyakiteOSX System Files Updater has updated $UpdatedFileCount files on your system. The updated files will be applied on the next reboot." Goto CLEANUP NotifyIcon::Icon /NOUNLOAD "fy" "${INST}\Tray.ico" NotifyIcon::Icon /NOUNLOAD "n" "System files have been updated" "The FlyakiteOSX System Files Updater has updated $UpdatedFileCount files on your system. The updated files will be applied on the next reboot." Sleep 10000 SetAutoClose true NotifyIcon::Icon "r" NOTSILENT: !insertmacro SetDetailsPrint "" !insertmacro SetDetailsPrint "$UpdatedFileCount files have been updated and will be applied on the next reboot." Call DeleteIconCache WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Session Manager" "AllowProtectedRenames" 0x00000001 CLEANUP: Delete "${INST_TOOLS}\ResHacker.ini" RMdir "${INST_BACKUP}" RMdir "${INST_LOGS}" RMdir "${INST_NEWFILES}" RMdir "${INST_RESOURCES}" RMdir /r "${INST_TEMPFILES}" SetOutPath $TEMP System::Free 0 SectionEnd #========================================== # INSTALLER FUNCTIONS #========================================== !include "Functions.nsi" Function .onInit InitPluginsDir Call OneInstance System::Call "kernel32::GetModuleHandle(t 'shell32.dll') i .s" System::Call "kernel32::GetProcAddress(i s, i 680) i .r0" System::Call "::$0() i .r0" StrCmp "$0" "1" +3 MessageBox MB_OK "The ${NAME} tool cannot be run on a limited user account. $\nThe ${NAME} will now quit." /SD IDOK Quit StrCpy $UpdatedFileCount "0" SetShellVarContext all FunctionEnd Function .onGuiEnd SetOutPath $TEMP System::Free 0 FunctionEnd